package com.concurrency.queue.ArrayBlockingQueue;

import java.util.Iterator;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

/**
 * add方法，队列满了报异常。
 *  take()方法和put()方法是对应的，从中拿一个数据，如果拿不到线程挂起
 *  poll()方法和offer()方法是对应的，从中拿一个数据，如果没有直接返回null
 * @author David
 *
 */
public class ArrayBlockingQueueTest {

	static BlockingQueue<String> queue = new ArrayBlockingQueue<String>(5);

	public static void main(String[] args){
		Producer producer = new Producer();
		producer.start();
		Consumer consumer = new Consumer();
		consumer.start();
	}
	
	
	private static void printQueue(){
		Iterator<String> it = queue.iterator();
		while(it.hasNext()){
			String s = it.next();
			System.out.println(s);
		}
		
	}
}
